﻿
// GIPSforDbgView.cpp : CGIPSforDbgView 类的实现
//

#include "stdafx.h"
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
// ATL 项目中进行定义，并允许与该项目共享文档代码。
#ifndef SHARED_HANDLERS
#include "GIPSforDbg.h"
#endif

#include "GIPSforDbgDoc.h"
#include "GIPSforDbgView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CGIPSforDbgView

IMPLEMENT_DYNCREATE(CGIPSforDbgView, CScrollView)

BEGIN_MESSAGE_MAP(CGIPSforDbgView, CScrollView)
	// 标准打印命令
	ON_COMMAND(ID_FILE_PRINT, &CScrollView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, &CScrollView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CGIPSforDbgView::OnFilePrintPreview)
	ON_WM_CONTEXTMENU()
	ON_WM_RBUTTONUP()
	ON_WM_TIMER()
	ON_MESSAGE(CVTORFV_MESSAGE, OnReceivingAtoBMsg)
END_MESSAGE_MAP()

// CGIPSforDbgView 构造/析构

CGIPSforDbgView *g_PV=0;
CString m_ItemStr;
extern double xyzt[4];
extern double svxyz[maxnumb][3];
extern double bsvxyz[maxnumb][3];
extern double rsvxyz[maxnumb][3];
extern int satnum[3];
extern int UserView;
extern int GridView;
extern BS_PR_CR_JH staInfo;
extern VBS_PR_CR gridInfo;
CGIPSforDbgView::CGIPSforDbgView()
{
	// TODO: 在此处添加构造代码
	g_PV=this;
	m_StaView=-1;
	m_GridInfoView=-1;

	m_brGreen.CreateSolidBrush(RGB(0,255,0));
	m_GrassGreen.CreateSolidBrush(RGB(124,252,0));
	m_brblue.CreateSolidBrush(RGB(0,150,255));
	m_bryello.CreateSolidBrush(RGB(255,255,0));
	m_TreesGreen.CreateSolidBrush(RGB(34,139,34));
	m_brRed.CreateSolidBrush(RGB(255,0,0));
	m_brBlack.CreateSolidBrush(RGB(0,0,0));
	m_brPurple.CreateSolidBrush(RGB(188,49,200));
	m_brPink.CreateSolidBrush(RGB(255,20,147));
	m_brFit.CreateSolidBrush(RGB(46,96,181));
	m_brWhite.CreateSolidBrush(RGB(255,255,255));
	m_brGray.CreateSolidBrush(RGB(107,107,107));
	m_brGray21.CreateSolidBrush(RGB(54,54,54));
	m_pPenRed=new CPen;
	m_pPenRed->CreatePen(PS_SOLID,1,RGB(255,0,0));
	m_pPenGreen=new CPen;
	m_pPenGreen->CreatePen(PS_SOLID,1,RGB(0,255,0));
	m_pPenWhite=new CPen;
	m_pPenWhite->CreatePen(PS_SOLID,0,RGB(255,255,255));
	m_pPenGray=new CPen;
	m_pPenGray->CreatePen(PS_SOLID,0,RGB(107,107,107));
	m_pPenPurple=new CPen;
	m_pPenPurple->CreatePen(PS_SOLID,0,RGB(118,28,112));
	m_pPenblue=new CPen;
	m_pPenblue->CreatePen(PS_SOLID,0,RGB(0,150,255));
	m_pPenPink=new CPen;
	m_pPenPink->CreatePen(PS_SOLID,0,RGB(186,15,0));
	m_pOldPen=NULL;
	m_pPenNull=new CPen;
	m_pPenNull->CreatePen(PS_NULL,0,RGB(0,0,0));

}

CGIPSforDbgView::~CGIPSforDbgView()
{
}

BOOL CGIPSforDbgView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: 在此处通过修改
	//  CREATESTRUCT cs 来修改窗口类或样式
	
	return CView::PreCreateWindow(cs);
}

// CGIPSforDbgView 绘制

void CGIPSforDbgView::OnDraw(CDC* pDC)
{
	CGIPSforDbgDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	#if 1
    
	CMainFrame* pApp = (CMainFrame*)AfxGetMainWnd();
	CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();

	CRect rect;
	double dms1[3]={0},dms2[3]={0};
	int k,bk,rk,x0,y0,r0,d0=300,dis20=20,dis100=100;
	if(UserView!=-1)
	{
		//绘制卫星星座图，周万振161027
		pDC->SetTextColor(RGB(255,0,0));//红色
		pDC->SelectObject(m_pPenGray);
		
   		int num=1,i;
	
 		for (i=0;i<num;i++)
		{
		
			r0=d0/2.0;
			int dx=dis20,dy=dis20;
			x0=dx+r0,y0=dy+r0;
			CRect satrect;
			satrect.SetRect(dx,dy,dx+d0,d0+dy);
			pDC->SelectObject(m_brGray21);
			pDC->Ellipse(&satrect);

			satrect.SetRect(dx+d0/6.0,dy+d0/6.0,dx+d0-d0/6.0,dy+d0-d0/6.0);
			pDC->SelectObject(m_brGray21);
			pDC->Ellipse(&satrect);
		
			satrect.SetRect(dx+d0/6.0+d0/6.0,dy+d0/6.0+d0/6.0,dx+d0-d0/6.0-d0/6.0,dy+d0-d0/6.0-d0/6.0);
			pDC->SelectObject(m_brGray21);
			pDC->Ellipse(&satrect);

			pDC->MoveTo(dx,y0);pDC->LineTo(dx+d0,y0);
			pDC->MoveTo(x0,dy);pDC->LineTo(x0,d0+dy);
		}

		//卫星云图名称
		CRect rectText;
		CString strText;
		rectText.left   = d0/2.0+dis20-120;
		rectText.top    = d0+dis20*2;
		rectText.right  = d0/2.0+dis20+120;
		rectText.bottom = d0+dis20*2+40;
		strText.Format(_T("%s卫星分布图"),pMainFrame->m_GNSSNetParse.m_fileName[UserView]);
		pDC->SetTextColor(RGB(0,0,0));//黑色
		pDC->DrawText(strText,&rectText, DT_CENTER | DT_LEFT);

		double xyz[3],pos[3],e[3],r;
		double azel[2],az[33],el[33],sat[33];
		double bazel[2],baz[33],bel[33],b_sat[33]={0},be[3],br;
		double razel[2],raz[33],rel[33],r_sat[33]={0},re[3],rr;
		xyz[0]=xyzt[0];xyz[1]=xyzt[1];xyz[2]=xyzt[2];
		k=0;bk=0;rk=0;
		int allsat=0;
		if(xyz[0]!=0&&xyz[1]!=0&&xyz[2]!=0)
		{
			m_cNDGNSS.ecef2pos(xyz,pos);
			for (i=1;i<33;i++)
			{
				if (fabs(svxyz[i][0])>1000 || fabs(svxyz[i][1])>1000|| fabs(svxyz[i][2])>1000)//gps
				{

					e[0]=svxyz[i][0]-xyz[0];
					e[1]=svxyz[i][1]-xyz[1];
					e[2]=svxyz[i][2]-xyz[2];
					r=m_cNDGNSS.norm(e,3);
					for(int j=0;j<3;j++) e[j]/=r;
					m_cNDGNSS.satazel(pos, e, azel);
					sat[k]=i;
					az[k]=azel[0];
					el[k++]=azel[1];

				}
				if (fabs(bsvxyz[i][0])>1000 || fabs(bsvxyz[i][1])>1000 || fabs(bsvxyz[i][2])>1000)//bds
				{
					be[0]=bsvxyz[i][0]-xyz[0];
					be[1]=bsvxyz[i][1]-xyz[1];
					be[2]=bsvxyz[i][2]-xyz[2];
					br=m_cNDGNSS.norm(be,3);
					for(int j=0;j<3;j++) be[j]/=br;
					m_cNDGNSS.satazel(pos, be, bazel);
					b_sat[bk]=i;
					baz[bk]=bazel[0];
					bel[bk++]=bazel[1];
				}
				if (fabs(rsvxyz[i][0])>1000 || fabs(rsvxyz[i][1])>1000 || fabs(rsvxyz[i][2])>1000)//glonass
				{
					re[0]=rsvxyz[i][0]-xyz[0];
					re[1]=rsvxyz[i][1]-xyz[1];
					re[2]=rsvxyz[i][2]-xyz[2];
					rr=m_cNDGNSS.norm(re,3);
					for(int j=0;j<3;j++) re[j]/=rr;
					m_cNDGNSS.satazel(pos, re, razel);
					r_sat[rk]=i;
					raz[rk]=razel[0];
					rel[rk++]=razel[1];
				}
			}
		}
		allsat=k+bk+rk;//所有卫星数
		int ellsize=10;//椭圆大小
		if (allsat>3)
		{
			for (int j=0;j<satnum[0];j++)//bds
			{
				double elevation =bel[j];
				double azimuth   =baz[j];
				double r=(90.0-elevation*180.0/PI)/90.0*(r0-10);
				double x1=r*sin(azimuth);
				double y1=r*cos(azimuth);
				x1=x1+x0;y1=-y1+y0;
				double x=x1;double y=y1;
				int prn= b_sat[j];
				if(1<=prn && prn<=15)//bds
				{
					if (elevation*180.0/PI>15)
					{
						pDC->SelectObject(&m_brPink);
					}
					else
					{
						pDC->SelectObject(&m_bryello);
					}
				}
				pDC->Ellipse(x-ellsize,y-ellsize,x+ellsize,y+ellsize);
				CString str;	
				str.Format(_T("%02d"),prn);
				pDC->SetTextColor(RGB(0,0,0));//设置字体为黑色
				pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
				rect.left=x-ellsize;
				rect.top=y-ellsize;
				rect.right=x+ellsize;
				rect.bottom=y+ellsize;
				DrawText(pDC->m_hDC, str, -1, &rect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
			}
			for (int j=0;j<satnum[1];j++)//gps
			{
				double elevation =el[j];
				double azimuth   =az[j];
				double r=(90.0-elevation*180.0/PI)/90.0*(r0-15);
				double x1=r*sin(azimuth);
				double y1=r*cos(azimuth);
				x1=x1+x0;y1=-y1+y0;
				double x=x1;double y=y1;
				int prn= sat[j];
				if(1<=prn && prn<=32)//GPS
				{
					if (elevation*180.0/PI>15)
					{
						pDC->SelectObject(&m_GrassGreen);
					}
					else
					{
						pDC->SelectObject(&m_bryello);
					}
				}
				pDC->Ellipse(x-ellsize,y-ellsize,x+ellsize,y+ellsize);
				CString str;	
				str.Format(_T("%02d"),prn);
				pDC->SetTextColor(RGB(0,0,0));//设置字体为黑色
				pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
				rect.left=x-ellsize;
				rect.top=y-ellsize;
				rect.right=x+ellsize;
				rect.bottom=y+ellsize;
				DrawText(pDC->m_hDC, str, -1, &rect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
			}
			for (int j=0;j<satnum[2];j++)//glonass
			{
				double elevation =rel[j];
				double azimuth   =raz[j];
				double r=(90.0-elevation*180.0/PI)/90.0*(r0-10);
				double x1=r*sin(azimuth);
				double y1=r*cos(azimuth);
				x1=x1+x0;y1=-y1+y0;
				double x=x1;double y=y1;
				int prn= r_sat[j];
				if(1<=prn && prn<=25)
				{
					if (elevation*180.0/PI>15)
					{
						pDC->SelectObject(&m_brblue);
					}
					else
					{
						pDC->SelectObject(&m_bryello);
					}
				}
				pDC->Ellipse(x-ellsize,y-ellsize,x+ellsize,y+ellsize);
				CString str;	
				str.Format(_T("%02d"),prn);
				pDC->SetTextColor(RGB(0,0,0));//设置字体为黑色
				pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
				rect.left=x-ellsize;
				rect.top=y-ellsize;
				rect.right=x+ellsize;
				rect.bottom=y+ellsize;
				DrawText(pDC->m_hDC, str, -1, &rect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
			}
		}
		CRect textRect;
		CString strInfo;
		BS_PR_CR_JH InsertData;
		memset(&InsertData,0x00,sizeof(InsertData));
		for(int num=0;num<staInfo.G_num;num++)
		{
			InsertData.GPC[staInfo.G_PRN[num]]=staInfo.GPC[num];
		}
		for(int num=0;num<staInfo.C_num;num++)
		{
			InsertData.CPC[staInfo.C_PRN[num]-160]=staInfo.CPC[num];
		}
		for(int num=0;num<staInfo.R_num;num++)
		{
			InsertData.RPC[staInfo.R_PRN[num]-32]=staInfo.RPC[num];
		}
		
		InsertData.tg=staInfo.tg;
		double eptt[6]={0};
		gtime_t tt =  m_cNDGNSS.gpst2time(InsertData.tg.week,InsertData.tg.second);
		m_cNDGNSS.time2epoch(tt,eptt);
		pDC->SetTextColor(RGB(0,0,0));//设置字体为黑色
		textRect.left=dis20*4;
		textRect.top=d0+dis20*4;
		textRect.right=dis20*4+200;
		textRect.bottom=d0+dis20*15;
		strInfo.Format(_T("%s站伪距差分信息：\n\nGPS卫星：%02d颗\n\nBDS卫星：%02d颗\n\nGLO卫星：%02d颗\n\nGPS时：%04d/%02d/%02d %02d:%02d:%02d\n\nGPS周：%d\n\n周内秒：%.1f")
			,pMainFrame->m_GNSSNetParse.m_fileName[UserView],staInfo.G_num,staInfo.C_num,staInfo.R_num,(int)eptt[0],(int)eptt[1],(int)eptt[2],(int)eptt[3],(int)eptt[4],(int)eptt[5],InsertData.tg.week,InsertData.tg.second);
		DrawText(pDC->m_hDC, strInfo, -1, &textRect, DT_LEFT| DT_VCENTER);

		for(int iprn=0;iprn<32;iprn++)//gps
		{
			pDC->SetTextColor(RGB(130,130,130));//设置字体为灰色
			//pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
			if(InsertData.GPC[iprn+1]!=0)
			{
				pDC->SetTextColor(RGB(0,0,0));//设置字体为黑色
			}
			textRect.left=d0+40;
			textRect.top=20*(iprn+1);
			textRect.right=d0+200;
			strInfo.Format("G%02d : %10.3f",iprn+1,InsertData.GPC[iprn+1]);
			textRect.bottom=20*(iprn+2);
			DrawText(pDC->m_hDC, strInfo, -1, &textRect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
		}
		for(int iprn=0;iprn<15;iprn++)//BDS
		{
			pDC->SetTextColor(RGB(130,130,130));//设置字体为灰色
			//pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
			if(InsertData.CPC[iprn+1]!=0)
			{
				pDC->SetTextColor(RGB(0,0,0));//设置字体为黑色
			}
			textRect.left=d0+220;
			textRect.top=20*(iprn+1);
			textRect.right=d0+380;
			strInfo.Format("C%02d : %10.3f",iprn+1,InsertData.CPC[iprn+1]);
			textRect.bottom=20*(iprn+2);
			DrawText(pDC->m_hDC, strInfo, -1, &textRect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
		}
		for(int iprn=0;iprn<24;iprn++)//GLO
		{
			pDC->SetTextColor(RGB(130,130,130));//设置字体为灰色
			//pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
			if(InsertData.RPC[iprn+1]!=0)
			{
				pDC->SetTextColor(RGB(0,0,0));//设置字体为黑色
			}
			textRect.left=d0+400;
			textRect.top=20*(iprn+1);
			textRect.right=d0+560;
			strInfo.Format("R%02d : %10.3f",iprn+1,InsertData.RPC[iprn+1]);
			textRect.bottom=20*(iprn+2);
			DrawText(pDC->m_hDC, strInfo, -1, &textRect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
		}
	}

	//每个网格属性信息
	if(GridView!=-1)
	{
		CRect textRect;
		CString strInfo;
		VBS_PR_CR InsertData;
		memset(&InsertData,0x00,sizeof(InsertData));
		for(int num=0;num<gridInfo.G_num;num++)
		{
			InsertData.GPC[gridInfo.G_PRN[num]]=gridInfo.GPC[num];
		}
		for(int num=0;num<gridInfo.C_num;num++)
		{
			InsertData.CPC[gridInfo.C_PRN[num]-160]=gridInfo.CPC[num];
		}
		for(int num=0;num<gridInfo.R_num;num++)
		{
			InsertData.RPC[gridInfo.R_PRN[num]-32]=gridInfo.RPC[num];
		}
		InsertData.tg=gridInfo.tg;
		double eptt[6]={0};
		gtime_t tt =  m_cNDGNSS.gpst2time(InsertData.tg.week,InsertData.tg.second);
		m_cNDGNSS.time2epoch(tt,eptt);
		pDC->SetTextColor(RGB(0,0,0));//设置字体为黑色
		textRect.left=dis20*4;
		textRect.top=dis20;
		textRect.right=dis20*4+200;
		textRect.bottom=dis20*14;
		strInfo.Format(_T("Grid%02d伪距差分信息：\n\nGPS卫星：%02d颗\n\nBDS卫星：%02d颗\n\nGLO卫星：%02d颗\n\nGPS时：%04d/%02d/%02d %02d:%02d:%02d\n\nGPS周：%d\n\n周内秒：%.1f\n\n播发端口：%d")
			,GridView+1,gridInfo.G_num,gridInfo.C_num,gridInfo.R_num,(int)eptt[0],(int)eptt[1],(int)eptt[2],(int)eptt[3],(int)eptt[4],(int)eptt[5],InsertData.tg.week,InsertData.tg.second
			,pMainFrame->m_GNSSNetParse.m_nSendToServerPort);
		DrawText(pDC->m_hDC, strInfo, -1, &textRect, DT_LEFT| DT_VCENTER);
		
		for(int iprn=0;iprn<32;iprn++)//gps
		{
			pDC->SetTextColor(RGB(130,130,130));//设置字体为灰色
			//pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
			if(InsertData.GPC[iprn+1]!=0)
			{
				pDC->SetTextColor(RGB(0,0,0));//设置字体为黑色
			}
			textRect.left=d0+40;
			textRect.top=20*(iprn+1);
			textRect.right=d0+200;
			strInfo.Format("G%02d : %10.3f",iprn+1,InsertData.GPC[iprn+1]);
			textRect.bottom=20*(iprn+2);
			DrawText(pDC->m_hDC, strInfo, -1, &textRect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
		}
		for(int iprn=0;iprn<15;iprn++)//BDS
		{
			pDC->SetTextColor(RGB(130,130,130));//设置字体为灰色
			//pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
			if(InsertData.CPC[iprn+1]!=0)
			{
				pDC->SetTextColor(RGB(0,0,0));//设置字体为黑色
			}
			textRect.left=d0+220;
			textRect.top=20*(iprn+1);
			textRect.right=d0+380;
			strInfo.Format("C%02d : %10.3f",iprn+1,InsertData.CPC[iprn+1]);
			textRect.bottom=20*(iprn+2);
			DrawText(pDC->m_hDC, strInfo, -1, &textRect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
		}
		for(int iprn=0;iprn<24;iprn++)//GLO
		{
			pDC->SetTextColor(RGB(130,130,130));//设置字体为灰色
			//pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
			if(InsertData.RPC[iprn+1]!=0)
			{
				pDC->SetTextColor(RGB(0,0,0));//设置字体为黑色
			}
			textRect.left=d0+400;
			textRect.top=20*(iprn+1);
			textRect.right=d0+560;
			strInfo.Format("R%02d : %10.3f",iprn+1,InsertData.RPC[iprn+1]);
			textRect.bottom=20*(iprn+2);
			DrawText(pDC->m_hDC, strInfo, -1, &textRect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
		}
	}

	//CORS站信息
	if(m_StaView==0)
	{
		//CRect rectClient;
		//GetClientRect(&rectClient);
		
		CRect rectScroll;
		rectScroll.left   = 0;
		rectScroll.right  = AREA_WIDTH;
		rectScroll.top    = 0;
		rectScroll.bottom = AREA_HEIGHT;  //大概先设置100条数据吧  ，每个表格：宽=50，高=20

		pDC->DrawText(_T("CORS站连接状态"),&rectScroll, DT_CENTER | DT_LEFT);

		for (int i = rectScroll.left; i <= rectScroll.right; i += 180)
		{
			pDC->MoveTo(i, rectScroll.top + 40);
			pDC->LineTo(i, rectScroll.bottom-40);
		}
 
		for (int i = rectScroll.top + 40; i < rectScroll.bottom; i += 40)
		{
			pDC->MoveTo(rectScroll.left, i);
			pDC->LineTo(rectScroll.right, i);
		}
		int x=0,y=1;
		for (int i=0;i<pMainFrame->m_GNSSNetParse.m_iServerIndex;i++)
		{
			CRect rectText;
			CString strText;
			strText.Format(_T("%s %10.4fMB"),pMainFrame->m_GNSSNetParse.m_fileName[i],pMainFrame->m_GNSSNetParse.m_fReceiveSize[i]/1024.0);
			rectText.left   = rectScroll.left + x*180;
			rectText.top    = rectScroll.top +55 + (y-1)*40;
			rectText.right  = rectScroll.left + (x+1)*180;
			rectText.bottom = rectScroll.top + 55 + y*40;
			pDC->DrawText(strText,&rectText, DT_CENTER | DT_LEFT);
			x++;
			if((i+1) % 5 == 0)
			{
				x = 0;
				y = y + 1;
			}
		}
	}

	//绘制网格与测站分布图
	if(m_GridInfoView==0)
	{
		double overTurnBL[2]={0.0};
		overTurnBL[0]=atof(pMainFrame->m_GNSSNetParse.m_strLONG0);//起始经度，X坐标
		overTurnBL[1]=atof(pMainFrame->m_GNSSNetParse.m_strLAT0);//起始纬度，y坐标
		double DLONG=atof(pMainFrame->m_GNSSNetParse.m_strDLONG);//经差
		double DLAT=atof(pMainFrame->m_GNSSNetParse.m_strDLAT);//纬差
		int NLONG=pMainFrame->m_GNSSNetParse.m_nNLONG;//水平方向网格数
		int NLAT=pMainFrame->m_GNSSNetParse.m_nNLAT;//竖直方向网格数

		CRect gridRect;
		gridRect.left=overTurnBL[0];
		gridRect.top=overTurnBL[1];
		gridRect.right=overTurnBL[0]+DLONG*NLONG*100;//图形放大100倍
		gridRect.bottom=overTurnBL[1]+DLAT*NLAT*100;
		
		pDC->Rectangle(gridRect);

		for(int col=1;col<NLONG;col++)
		{
			pDC->MoveTo(overTurnBL[0]+col*DLONG*100, gridRect.top);
			pDC->LineTo(overTurnBL[0]+col*DLONG*100, gridRect.bottom);
		}
		for(int row=1;row<NLAT;row++)
		{
			pDC->MoveTo(gridRect.left,overTurnBL[1]+row*DLAT*100);
			pDC->LineTo(gridRect.right,overTurnBL[1]+row*DLAT*100);
		}

		CRect latlonRect;
		for(int col=0;col<=NLONG;col++)//经度标注
		{
			latlonRect.left=overTurnBL[0]+col*DLONG*100-20;
			latlonRect.top=overTurnBL[1]+DLAT*NLAT*100+10;
			latlonRect.right=overTurnBL[0]+col*DLONG*100+20;//图形放大100倍
			latlonRect.bottom=overTurnBL[1]+DLAT*NLAT*100+20;
			pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
			CString latlonstr;
			latlonstr.Format(_T("%4.1f"),overTurnBL[0]+DLONG*col);
			DrawText(pDC->m_hDC, latlonstr, -1, &latlonRect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
		}
		
		for(int row=0;row<=NLAT;row++)//纬度标注
		{
			latlonRect.left=overTurnBL[0]-50;
			latlonRect.top=overTurnBL[1]+row*DLAT*100-5;
			latlonRect.right=overTurnBL[0]-10;//图形放大100倍
			latlonRect.bottom=overTurnBL[1]+row*DLAT*100+5;
			pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
			CString latlonstr;
			latlonstr.Format(_T("%4.1f"),overTurnBL[1]+NLAT*DLAT-DLAT*row);
			DrawText(pDC->m_hDC, latlonstr, -1, &latlonRect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
		}
		
		latlonRect.left=overTurnBL[0]+NLONG*DLONG*50-100;
		latlonRect.top=overTurnBL[1]+DLAT*NLAT*100+40;
		latlonRect.right=overTurnBL[0]+NLONG*DLONG*50+100;
		latlonRect.bottom=overTurnBL[1]+DLAT*NLAT*100+60;
		DrawText(pDC->m_hDC, _T("网格划分与CORS站分布"), -1, &latlonRect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);

		CRect staRect;
		double staXYZ[3]={0};
		double staPOS[3]={0};
		int magnDlat=DLAT*NLAT*100;//放大100倍后的纬度范围
		for(int i=0;i<pMainFrame->m_GNSSNetParse.m_Nums;i++)
		{
			memset(staXYZ,0x00,sizeof(staXYZ));
			memset(staPOS,0x00,sizeof(staPOS));
			staXYZ[0]=pMainFrame->m_GNSSNetParse.m_PositionX[i];
			staXYZ[1]=pMainFrame->m_GNSSNetParse.m_PositionY[i];
			staXYZ[2]=pMainFrame->m_GNSSNetParse.m_PositionZ[i];
			m_cNDGNSS.ecef2pos(staXYZ,staPOS);
			staPOS[0]=staPOS[0]*R2D;//纬度
			staPOS[1]=staPOS[1]*R2D;//经度
			double x=overTurnBL[0]+(staPOS[1]-overTurnBL[0])*100;
			double y=(magnDlat+overTurnBL[1])-(staPOS[0]-overTurnBL[1])*100;
			pDC->SelectObject(&m_brblue);
			pDC->Ellipse(x-5,y-5,x+5,y+5);
			staRect.left=x-30;
			staRect.top=y+10-5;
			staRect.right=x+30;
			staRect.bottom=y+10+5;
			pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明色
			DrawText(pDC->m_hDC, pMainFrame->m_GNSSNetParse.m_fileName[i], -1, &staRect, DT_CENTER| DT_VCENTER | DT_SINGLELINE);
		}

	}
#endif

	// TODO: 在此处为本机数据添加绘制代码
}


// CGIPSforDbgView 打印


void CGIPSforDbgView::OnFilePrintPreview()
{
#ifndef SHARED_HANDLERS
	AFXPrintPreview(this);
#endif
}

BOOL CGIPSforDbgView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// 默认准备
	return DoPreparePrinting(pInfo);
}

void CGIPSforDbgView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 添加额外的打印前进行的初始化过程
}

void CGIPSforDbgView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 添加打印后进行的清理过程
}


void CGIPSforDbgView::OnRButtonUp(UINT /* nFlags */, CPoint point)
{
	ClientToScreen(&point);
	OnContextMenu(this, point);
}

void CGIPSforDbgView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
{
#ifndef SHARED_HANDLERS
	theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
#endif
}


// CGIPSforDbgView 诊断

#ifdef _DEBUG
void CGIPSforDbgView::AssertValid() const
{
	CView::AssertValid();
}

void CGIPSforDbgView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CGIPSforDbgDoc* CGIPSforDbgView::GetDocument() const // 非调试版本是内联的
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGIPSforDbgDoc)));
	return (CGIPSforDbgDoc*)m_pDocument;
}
#endif //_DEBUG


// CGIPSforDbgView 消息处理程序

BOOL CGIPSforDbgView::OnScrollBy(CSize sizeScroll, BOOL bDoScroll)
{
// 	CClientDC dc(this);
// 	CRect rcText(0, 0, 100, 30);
// 	dc.DPtoLP(rcText);
 	//Invalidate();
	BOOL b = CScrollView::OnScrollBy(sizeScroll, bDoScroll);
	return b;
}

void CGIPSforDbgView::OnInitialUpdate()
{
	CView::OnInitialUpdate();
	CSize szArea(AREA_WIDTH+40, AREA_HEIGHT);
	//CSize szDoc(0, 25*1000);
	SetScrollSizes(MM_TEXT, szArea);
	SetTimer(1,1000,NULL);
	// TODO: Add your specialized code here and/or call the base class
}


void CGIPSforDbgView::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: Add your message handler code here and/or call default
	Invalidate(TRUE);
	CView::OnTimer(nIDEvent);
}

BOOL CGIPSforDbgView::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
	// TODO: Add your specialized code here and/or call the base class

	return CScrollView::OnWndMsg(message, wParam, lParam, pResult);
}
LRESULT CGIPSforDbgView::OnReceivingAtoBMsg(WPARAM wParam, LPARAM lParam)
{
	CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
	CString getItemUserNameStr=m_ItemStr.Trim();
	
	if(getItemUserNameStr.Compare("CORS站信息") == 0)
	{
		m_StaView=0;//CORS站信息index
		UserView=-1;//各个CORS站信息index
		m_GridInfoView=-1;//网格信息index
		GridView=-1;//各个网格信息index
		CString strContext;  
		strContext.Format(_T("选择>>CORS站信息"));  
		pMainFrame->m_wndOutput.AddStrToOutputBuild(strContext);
		return 1;
	}
	if(getItemUserNameStr.Compare("网格信息") == 0)
	{
		m_StaView=-1;
		UserView=-1;
		m_GridInfoView=0;
		GridView=-1;
		CString strContext;  
		strContext.Format(_T("选择>>网格信息"));  
		pMainFrame->m_wndOutput.AddStrToOutputBuild(strContext);
		return 1;
	}
	for(int i=0;i<pMainFrame->m_GNSSNetParse.m_Nums;i++)
	{
		CString userNameStr=pMainFrame->m_GNSSNetParse.m_fileName[i].Trim();
		if(getItemUserNameStr.Compare(userNameStr) == 0)
		{
			m_StaView=-1;
			UserView=i;
			m_GridInfoView=-1;
			GridView=-1;
			CString strContext;  
			strContext.Format(_T("选择>>%s"),userNameStr);  
			pMainFrame->m_wndOutput.AddStrToOutputBuild(strContext);
			return 1;
		}
	}
	for(int i=0;i<pMainFrame->m_GNSSNetParse.m_nNLONG*pMainFrame->m_GNSSNetParse.m_nNLAT;i++)
	{
		CString gridIDStr;
		gridIDStr.Format(_T("Grid%02d"),i+1);
		if(getItemUserNameStr.Compare(gridIDStr) == 0)
		{
			m_StaView=-1;
			UserView=-1;
			m_GridInfoView=-1;
			GridView=i;
			CString strContext;  
			strContext.Format(_T("选择>>%s"),gridIDStr);  
			pMainFrame->m_wndOutput.AddStrToOutputBuild(strContext);
			return 1;
		}
	}
	return 1;
}



